package com.egao.oa.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
//import com.egao.oa.mapper.AssetsMapper;
import com.egao.oa.entity.Assets;
import com.egao.oa.service.AssetsService;
import org.springframework.stereotype.Service;
import com.egao.oa.biz.AssetsBiz;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * 固定资产服务实现类
 * @author : Doman
 * @date : 2020-08-19 16:54:05
 * @version ：1.0
 */
@Service
public class AssetsServiceImpl /*extends ServiceImpl<AssetsMapper, Assets> */implements AssetsService {

	@Autowired
	private AssetsBiz assetsBiz;

    /**
    @Override
    public PageResult<Assets> listPage(PageParam<Assets> page) {
        List<Assets> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<Assets> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, Assets assets, User loginUser)  throws Exception{
        return assetsBiz.list(page,assets,loginUser);
    }

    @Override
    public List<Assets> list(Assets assets, User loginUser) {
        return assetsBiz.list(assets,loginUser);
    }

    @Override
    public JsonResult getById(Assets assets) {
        return JsonResult.ok().setData(assetsBiz.getById(assets));
    }

    @Transactional
    @Override
    public JsonResult save(Assets assets, User loginUser) {
        if (assetsBiz.save(assets, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Transactional
    @Override
    public JsonResult update(Assets assets, User loginUser) {
        if (assetsBiz.update(assets, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult remove(Assets assets, User loginUser) {
        if (assetsBiz.remove(assets, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
